/* -----------------------------------------------------------------------
 * Andrew Goetz
 * CS362
 * cardtest2.c
 * Tests the ambassador card
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <stdlib.h>
#include <math.h>

#define CARD_FUNCTION 1
#define TRIALS 250  // Number of times the test runs variable

int main(){

	int i;
	int j; 
	int player;
	int numPlayers;
	int value;
	int handPos;
	int op1;
	int op2;
	int op3;
	int bonus = 1;
	enum CARD card = great_hall;
	enum CARD begCard = curse;
    enum CARD endCard = treasure_map;
	struct gameState *state = malloc(sizeof(struct gameState));
    PlantSeeds(3);
	SelectStream(2);
	
    assert(state != 0);
	
    if(CARD_FUNCTION == 0){
        for(j = 0; j <= TRIALS; j++){ 
            for(i = 0; i < sizeof(struct gameState); i++){
                ((char*)state)[i] = floor(Random()*256);
            }
            numPlayers = floor(Random()*3);
            state->numPlayers = numPlayers;
            player = (Random()*numPlayers)+1;
            handPos = (Random()*MAX_HAND);
            value = ambassadorCard(player, handPos, state);
            assert(value == 0);
        }
        printf("Tests finished\n");
        
    }
    else{
        for(j = 0; j <= TRIALS; j++){
            for(i = 0; i < sizeof(struct gameState); i++){
                ((char*)state)[i] = floor(Random()*256);
            }
            numPlayers = floor(Random()*4);
            state->numPlayers = numPlayers;
            player = (Random()*numPlayers )+1;
            handPos = (Random()*MAX_HAND);
            op1 = (Random() * (endCard-begCard)) + begCard;
            op2 = (Random() * (endCard-begCard)) + begCard;
            op3 = (Random() * (endCard-begCard)) + begCard;
            cardEffect(card, op1, op2, op3, state, handPos, &bonus);
        }
    }
    printf("Tests finished\n");
    return 0;
}